import axios from 'axios'
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'
const service =axios.create({
    baseURL:'/api',//配置接口请求公共部分
    timeout:'20000'
})
//请求拦截的请求报文
service.interceptors.request.use(
    (config) => {
        Nprogress.start()
        return config
    },
);
//拦截响应报文
service.interceptors.response.use(
    (response) => {
        Nprogress.done();//关闭进度条
        return response.data
    },
    (error) => {
        Nprogress.done()
        alert('请求失败' + error.message || '未知错误')
        return new Promise(() => {})
    }
);
export default service